<template>
    <div id="collection">
        <div class="title-wrap">
            <div class="name">
                {{bsr.meta_info.name}}
            </div>
            <div class="title-btns">
                <img src="../../assets/img/mini-w.png" @click="$electron.ipcRenderer.send('resource-window-minimize',{metaId:bsr.id})" alt="" />
                <img src="../../assets/img/close-w.png" @click="$electron.ipcRenderer.send('close-resource-window',{metaId:bsr.id})" alt="" />
            </div>
        </div>
        <!-- <home-container :metaId="bsr.id"> -->
            <div class="collection-container ">
                <router-view></router-view>
                <!-- <div>11</div>
                <div class="collection-content" style="-webkit-app-region: no-drag;">
                    <router-view></router-view>
                </div> -->
            </div>
        <!-- </home-container> -->
        <div class="align-center tool-container">
            <div :class="['pointer', 'align-start','toolactive', active?'tool-animation-a':'tool-animation-na']" ref="toolkit">
                <img src="../../assets/img/menu.png" alt="" style="margin-top:25px" @click="showIntro">
                <img src="../../assets/img/close-circle.png" @click="$electron.ipcRenderer.send('close-resource-window',{metaId:bsr.id})" alt="" style="margin-top:14px">
            </div>
            <div class="bottom-toolkit align-center pointer" @click="showToolkit">
                <img src="../../assets/img/active.png" alt="" v-if="active">
                <img src="../../assets/img/resource-toolkit.png" alt="" v-else>
            </div>
        </div>
        <div class="intro align-center" v-if="introSign">
            <div class="close-inter pointer" @click="showIntro">
                <i class="el-icon-close"></i>
            </div>
            <div class="title">简介</div>
            <el-divider></el-divider>
            {{intro.trim()?intro:'暂无简介'}}
        </div>
        <div class="bigImg" v-if="showImg">
            <div>
                <img :src="imgSrc" alt="">
                <div class="close pointer" @click="showImg = false">
                <button>关闭</button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import homeContainer from '../../components/background'
import mixin from '../../mixin/mixin'
import bus from '../../../content/assets/js/bus'
export default {
    mixins: [mixin],
    components: { homeContainer },
    data() {
        return {
            active: false,
            title: '',
            intro: '',
            introSign: false,
            showImg:false,
            imgSrc:'',
        }
    },
    mounted() {
        if (this.bsr) {
            let type = JSON.parse(this.bsr.description).resType
            this.intro = this.bsr.intro
            localStorage.setItem('collection', JSON.stringify(this.bsr))
            console.log('type-----------------',type);
            if (this.$route.fullPath === ('/Collection/' + type)) return
            this.$router.push({ name: type })
        }
        bus.$on('showbigImg',(val)=>{
            console.log('val',val);
            this.showImg = true
            this.imgSrc  = val.src
        })
    },
    methods: {
        showIntro() {
            this.introSign = !this.introSign
        },
        showToolkit() {
            this.active = !this.active
        },
    },
}
</script>

<style lang="scss">
#collection {
    .title-wrap {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 3.3vw;
        background-image: url("../../assets/img/title_bg.png");
        background-size: cover;
        -webkit-app-region: drag;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 30px;
        box-sizing: border-box;
        z-index: 9;
        .title-btns {
            position: absolute;
            top: 1.2vw;
            right: 1.3vw;
            -webkit-app-region: no-drag;
            img {
                width: 14px;
                height: 14px;
                margin-left: 18px;
                cursor: pointer;
            }
        }
        .name {
            transform: translateX(20px);
            z-index: 999!important;
            font-size: 1.6vw;
            color: #fff;
        }
    }
    .collection-container {
        position: absolute;
        top: 3.3vw;
        height:  calc(100vh - 3.3vw);;
        width: 100vw;
        background-image: url(../../assets/img/echarts_bg.jpg);
        background-repeat: no-repeat;
        background-size: cover;
        overflow: hidden;
        font-size: 16px;
        padding-top: 25px;
        // .collection-content {
        //     height: calc(100vh - 64px);
        //     width: 100%;
        // }
    }
    @media screen and(max-width: 1439px) {
        .collection-container {
            font-size: 14px;
        }
    }
    .tool-container {
        position: fixed;
        bottom: 15.2vw;
        right: 22px;
        width: 60px;
        z-index: 2048;
    }
    .bottom-toolkit {
        position: fixed;
        bottom: 15.2vw;
        right: 22px;
        z-index: 100;
        img {
            width: 60px;
            height: 60px;
        }
    }
    .toolactive {
        background-image: url(../../assets/img/toolkit-bg.png);
        background-size: 100% 100%;
        height: 0;
        width: 48px;
        opacity: 0;
        overflow: hidden;
        img {
            width: 24px;
            height: 24px;
        }
    }
    .tool-animation-a {
        animation: showheight 0.7s ease forwards;
    }
    .tool-animation-na {
        animation: hiddenheight 0.7s ease forwards;
    }
    @keyframes showheight {
        form {
            height: 0;
        }
        to {
            opacity: 1;
            height: 150px;
        }
    }
    @keyframes hiddenheight {
        form {
            height: 150px;
        }
        to {
            height: 0;
        }
    }
    .intro {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background-color: rgba(240, 248, 254, 1);
        color: #333;
        width: 400px;
        border-radius: 8px;
        padding: 20px;
        font-size: 14px;
        z-index: 1024;
        .title {
            font-size: 20px;
            font-weight: 500;
            color: #000;
        }
        .close-inter {
            position: absolute;
            top: 10px;
            right: 10px;
        }
    }

    .bigImg{
        position: fixed;
        background: #ffffff;
        border: 6px solid #ABBCD0;
        top: 3.3vw;
        left: calc(50% - 23.9vw);
        // transform: translate(-50%, -50%);
        width: 47.8vw;
        height: 35.6vw;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 99;
        .close{
            display: flex;
            justify-content: center;
            button{
                cursor: pointer;
                width: 8vw;
                height: 2.8vw;
                color: #fff;
                font-size: 1.25vw;
                background: #4894FF;
                border-radius: 27px;
            }
        }
        img{
            width:  28vw;
            height: 28vw;
            z-index: 999!important;
            border-radius: 10px;
            margin-bottom: 1vw;
        }
    }
}
</style>